package com.blz.flare.data;

import java.util.Collection;
import java.util.LinkedList;
import java.util.NoSuchElementException;
import java.util.Queue;

/**
 * A {@link java.util.Queue} that is serialized.
 * @param <T> the type
 *
 * @author pchapman, jeremy.arnold
 */
public class SerializedQueue<T> extends LinkedList<T> implements Queue<T> {

    /**
     * Construct the {@link Queue}.
     * @param c a collection to add to the queue
     */
	public SerializedQueue(Collection<? extends T> c) {
		super(c);
	}

    /**
     * {@inheritDoc}
     */
	@Override
	public synchronized boolean add(T e) {
		return super.add(e);
	}

	/**
     * {@inheritDoc}
     */
	@Override
	public synchronized T element() {
		return super.element();
	}

	/**
     * {@inheritDoc}
     */
	@Override
	public synchronized boolean offer(T e) {
		return super.offer(e);
	}

	/**
     * {@inheritDoc}
     */
	@Override
	public synchronized T peek() {
		return super.peek();
	}

	/**
     * {@inheritDoc}
     */
	@Override
	public synchronized T poll() {
		try {
			return super.poll();
		} catch (NoSuchElementException e) {
			return null;
		}
	}

	/**
     * {@inheritDoc}
     */
	@Override
	public synchronized T remove() {
		try {
			return super.remove();
		} catch (NoSuchElementException e) {
			return null;
		}
	}
}
